// CherryMerry ( Mikhail Tomilenko ), Reverse Entertainment, 2021-2024

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"

#include "PlayerUIManager.h"

#include "PlayerHealthManager.generated.h"


UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class NIFESTGAME_API UPlayerHealthManager : public UActorComponent
{
	GENERATED_BODY()

protected:

	/* Functions */

	UFUNCTION()
	void DoDamage(float Damage);

	UFUNCTION(BlueprintCallable)
	void DoHealHealth(float toHeal);

	UFUNCTION(BlueprintCallable)
	void DoHealShield(float toHeal);

	UFUNCTION()
	virtual void Death();

	UFUNCTION()
	void TakeDamage(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser);

	/* Variables */
	UPROPERTY(BlueprintReadOnly, Category = "Death")
	bool bDead;

	bool bCanHealHealth;
	bool bCanHealShield;

	class UPlayerUIManager* UIManager;

public:
	UPlayerHealthManager();

	/* Functions */

	UFUNCTION(BlueprintCallable)
	virtual void Respawn();

	UFUNCTION(BlueprintCallable)
	virtual void UpdateHealthAndShield(float NewMaxHealth, float NewMaxShield);

	UFUNCTION(BlueprintCallable)
	virtual void UseTotem();

	UFUNCTION(BlueprintCallable)
	virtual void AddTotem();

	/* Variables */
	UPROPERTY(BlueprintReadOnly, Category = "Totems")
	int32 MaxTotemsAmount;

	UPROPERTY(BlueprintReadOnly, Category = "Totems")
	int32 CurrentTotemsAmount;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health")
	float MaxHealth;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shield")
	float MaxShield;

	UPROPERTY(BlueprintReadOnly, Category = "Health")
	float CurrentHealth;

	UPROPERTY(BlueprintReadOnly, Category = "Shield")
	float CurrentShield;

	bool bCanDamage;

protected:
	virtual void BeginPlay() override;

};